package com.store.app.activity;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.Resources;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.store.app.BaseActivity;
import com.store.app.ExitApplication;
import com.store.app.MainActivity;
import com.store.app.R;
import com.store.app.bean.ServiceUpdateBean;
import com.store.app.http.Stores;
import com.store.app.http.Submit;
import com.store.app.utils.GoToLogin;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import de.greenrobot.event.EventBus;

/**
 * 服务页面
 */
public class ServiceActivity extends BaseActivity {
    private Context context;
    EditText money_one, amount, money_two, quantity;
    ImageView serve_one, serve_two, serve_three, serve_four, serve_five, serve_six, serve_seven, serve_eight, serve_nine, serve_ten, serve_eleven, serve_twelve;
    ImageView other_services1, other_services2, other_services3, other_services4, other_services5, other_services6, other_services7, other_services8, other_services9, other_services10, other_services11, other_services12, other_services13;


    View imageView;
    String error;
    Handler handler;
    TextView submit;
    private List<Integer> tempList;//临时数据
    private boolean ifSubmit;//是否提交
    private GoToLogin goToLogin;
    private TextView tv_wifi;
    private TextView tv_wc;
    private TextView tv_hot_water;
    private TextView tv_hot_food;
    private TextView tv_pump;
    private TextView tv_battery;
    private TextView tv_breaker;
    private TextView tv_express;
    private TextView tv_charge;
    private TextView tv_pay;
    private TextView tv_tools;
    private TextView tv_toy_car;
    private TextView tv_recycle;
    private TextView tv_lock;
    private TextView tv_move_house;
    private TextView tv_dredge;
    private TextView tv_broadband;
    private TextView tv_clothes;
    private TextView tv_serve;
    private TextView tv_cake;
    private TextView tv_flower;
    private TextView tv_milk;
    private TextView tv_rent_car;
    private TextView tv_maintain;
    private TextView tv_phone_recycle;

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.type_service);
        initView();

        //透明状态栏
//		getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        context = ServiceActivity.this;
        ExitApplication.getInstance().addActivity(this);
        tempList = new ArrayList<>();
         String activity_service = getIntent().getStringExtra("activity_service");
        if(TextUtils.isEmpty(activity_service)){
            activity_service  = "[]";
        }
        Log.v("zyl", "activity_service:" + activity_service);
        final String temp_activity_servcie = activity_service.substring(1, activity_service.length() - 1).replaceAll(" ", "");
        if (!TextUtils.isEmpty(temp_activity_servcie)) {
            String[] sourceStrArray = temp_activity_servcie.split(",");
            for (int i = 0; i < sourceStrArray.length; i++) {
                if (!tempList.contains(Integer.valueOf(sourceStrArray[i]).intValue())) {
                    tempList.add(Integer.valueOf(sourceStrArray[i]).intValue());//Integer.parseInt(sourceStrArray[i]));
                }
            }
        }

        goToLogin = new GoToLogin(this);
//		Log.v("zyl","Stores.service:"+Stores.type_service.toString());
//		for (int i =0;i<Stores.type_service.size();i++){
//			Log.v("zyl","Stores.type_service:"+Stores.type_service.get(i));
//			tempList.add(Stores.type_service.get(i));
//		}
        Log.v("zyl", "tempList:" + tempList.toString());

        final Resources resources = getResources();

        //公益回收箱
        other_services1 = (ImageView) findViewById(R.id.other_services1);
        other_services1.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                if (tempList.contains(13)) {
                    other_services1.setBackgroundResource(R.drawable.gy_bigicongray);
                    tv_recycle.setTextColor(resources.getColor(R.color.service_text_color_normal));
                    deleteelement(13);
                } else {
                    other_services1.setBackgroundResource(R.drawable.gy_bigiconorg);
                    tv_recycle.setTextColor(resources.getColor(R.color.service_text_color));
                    tempList.add(13);
                }
            }
        });

        //便民开锁
        other_services2 = (ImageView) findViewById(R.id.other_services2);
        other_services2.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                if (tempList.contains(14)) {
                    other_services2.setBackgroundResource(R.drawable.suo_bigicongray);
                    tv_lock.setTextColor(resources.getColor(R.color.service_text_color_normal));
                    deleteelement(14);
                } else {
                    other_services2.setBackgroundResource(R.drawable.suo_bigiconorg);
                    tv_lock.setTextColor(resources.getColor(R.color.service_text_color));
                    tempList.add(14);
                }
            }
        });

        //便民搬家
        other_services3 = (ImageView) findViewById(R.id.other_services3);
        other_services3.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                if (tempList.contains(15)) {
                    other_services3.setBackgroundResource(R.drawable.sh_bigicongray);
                    tv_move_house.setTextColor(resources.getColor(R.color.service_text_color_normal));
                    deleteelement(15);
                } else {
                    other_services3.setBackgroundResource(R.drawable.sh_group);
                    tv_move_house.setTextColor(resources.getColor(R.color.service_text_color));
                    tempList.add(15);
                }
            }
        });

        //管道疏通
        other_services4 = (ImageView) findViewById(R.id.other_services4);
        other_services4.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                if (tempList.contains(16)) {
                    other_services4.setBackgroundResource(R.drawable.tong_bigicongray);
                    tv_dredge.setTextColor(resources.getColor(R.color.service_text_color_normal));
                    deleteelement(16);
                } else {
                    other_services4.setBackgroundResource(R.drawable.tong_bigiconorg);
                    tv_dredge.setTextColor(resources.getColor(R.color.service_text_color));
                    tempList.add(16);
                }
            }
        });

        //干洗代收
        other_services5 = (ImageView) findViewById(R.id.other_services5);
        other_services5.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                if (tempList.contains(17)) {
                    other_services5.setBackgroundResource(R.drawable.gx_bigicongray);
                    tv_clothes.setTextColor(resources.getColor(R.color.service_text_color_normal));
                    deleteelement(17);
                } else {
                    other_services5.setBackgroundResource(R.drawable.gx_bigiconorg);
                    tv_clothes.setTextColor(resources.getColor(R.color.service_text_color));
                    tempList.add(17);
                }
            }
        });

        //家政服务
        other_services6 = (ImageView) findViewById(R.id.other_services6);
        other_services6.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                if (tempList.contains(18)) {
                    other_services6.setBackgroundResource(R.drawable.group_copy);
                    tv_serve.setTextColor(resources.getColor(R.color.service_text_color_normal));
                    deleteelement(18);
                } else {
                    other_services6.setBackgroundResource(R.drawable.group_copyorg);
                    tv_serve.setTextColor(resources.getColor(R.color.service_text_color));
                    tempList.add(18);
                }
            }
        });
        //移动支付
        other_services7 = (ImageView) findViewById(R.id.other_services7);
        other_services7.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
//				for (int i=0;i<tempList.size();i++){
//					Log.v("zyl","tempList:"+tempList.get(i));
//				}


                if (tempList.contains(19)) {
                    other_services7.setBackgroundResource(R.drawable.pay2_bigicongray);
                    tv_pay.setTextColor(resources.getColor(R.color.service_text_color_normal));
                    deleteelement(19);
                } else {
                    other_services7.setBackgroundResource(R.drawable.pay2_bigiconorg);
                    tv_pay.setTextColor(resources.getColor(R.color.service_text_color));

                    tempList.add(19);
                }
            }
        });

        //家电维修
        other_services8 = (ImageView) findViewById(R.id.other_services8);
        other_services8.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
//				for (int i=0;i<tempList.size();i++){
//					Log.v("zyl","tempList:"+tempList.get(i));
//				}

                if (tempList.contains(20)) {
                    other_services8.setBackgroundResource(R.drawable.wx_bigicongray);
                    tv_maintain.setTextColor(resources.getColor(R.color.service_text_color_normal));
                    deleteelement(20);
                } else {
                    other_services8.setBackgroundResource(R.drawable.wx_bigiconorg);
                    tv_maintain.setTextColor(resources.getColor(R.color.service_text_color));
                    tempList.add(20);
                }
            }
        });
        //工具箱
        other_services9 = (ImageView) findViewById(R.id.other_services9);
        other_services9.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
//				for (int i=0;i<tempList.size();i++){
//					Log.v("zyl","tempList:"+tempList.get(i));
//				}
                if (tempList.contains(21)) {
                    other_services9.setBackgroundResource(R.drawable.tool_bigicongray);
                    tv_tools.setTextColor(resources.getColor(R.color.service_text_color_normal));
                    deleteelement(21);
                } else {
                    other_services9.setBackgroundResource(R.drawable.tool_bigiconorg);
                    tv_tools.setTextColor(resources.getColor(R.color.service_text_color));
                    tempList.add(21);
                }
            }
        });

        //摇摆车
        other_services10 = (ImageView) findViewById(R.id.other_services10);
        other_services10.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                if (tempList.contains(22)) {
                    other_services10.setBackgroundResource(R.drawable.yyc_bigicongray);
                    tv_toy_car.setTextColor(resources.getColor(R.color.service_text_color_normal));
                    deleteelement(22);
                } else {
                    other_services10.setBackgroundResource(R.drawable.yyc_bigiconorg);
                    tv_toy_car.setTextColor(resources.getColor(R.color.service_text_color));
                    tempList.add(22);
                }
            }
        });


        //租车代价
        other_services11 = (ImageView) findViewById(R.id.other_services11);
        other_services11.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                if (tempList.contains(23)) {
                    other_services11.setBackgroundResource(R.drawable.tx_bigicongray);
                    tv_rent_car.setTextColor(resources.getColor(R.color.service_text_color_normal));
                    deleteelement(23);
                } else {
                    other_services11.setBackgroundResource(R.drawable.tx_bigiconorg);
                    tv_rent_car.setTextColor(resources.getColor(R.color.service_text_color));
                    tempList.add(23);
                }
            }
        });

        //手机回收
        other_services12 = (ImageView) findViewById(R.id.other_services12);
        other_services12.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                if (tempList.contains(24)) {
                    other_services12.setBackgroundResource(R.drawable.rc_bigicongray);
                    tv_phone_recycle.setTextColor(resources.getColor(R.color.service_text_color_normal));
                    deleteelement(24);
                } else {
                    other_services12.setBackgroundResource(R.drawable.rc_bigiconorg);
                    tv_phone_recycle.setTextColor(resources.getColor(R.color.service_text_color));
                    tempList.add(24);
                }
            }
        });

        //宽带安装
        other_services13 = (ImageView) findViewById(R.id.other_services13);
        other_services13.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                if (tempList.contains(25)) {
                    other_services13.setBackgroundResource(R.drawable.ly_bigicongray);
                    tv_broadband.setTextColor(resources.getColor(R.color.service_text_color_normal));
                    deleteelement(25);
                } else {
                    other_services13.setBackgroundResource(R.drawable.ly_bigiconorg);
                    tv_broadband.setTextColor(resources.getColor(R.color.service_text_color));
                    tempList.add(25);
                }
            }
        });

        //wifi
        serve_one = (ImageView) findViewById(R.id.serve_one);
        serve_one.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                if (tempList.contains(1)) {
                    serve_one.setBackgroundResource(R.drawable.wifi_bigicongray);
                    tv_wifi.setTextColor(resources.getColor(R.color.service_text_color_normal));
                    deleteelement(1);
                } else {
                    serve_one.setBackgroundResource(R.drawable.wifi_bigiconorg);
                    tv_wifi.setTextColor(resources.getColor(R.color.service_text_color));
                    tempList.add(1);
                }

            }
        });

        //厕所
        serve_two = (ImageView) findViewById(R.id.serve_two);
        serve_two.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {

                if (tempList.contains(2)) {
                    serve_two.setBackgroundResource(R.drawable.wc_bigicongray);
                    tv_wc.setTextColor(resources.getColor(R.color.service_text_color_normal));
                    deleteelement(2);
                } else {
                    serve_two.setBackgroundResource(R.drawable.wc_bigiconorg);
                    tv_wc.setTextColor(resources.getColor(R.color.service_text_color));
                    tempList.add(2);
                }
            }
        });

        //热水
        serve_three = (ImageView) findViewById(R.id.serve_three);
        serve_three.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {

                if (tempList.contains(3)) {
                    serve_three.setBackgroundResource(R.drawable.hot2_bigicongray);
                    tv_hot_water.setTextColor(resources.getColor(R.color.service_text_color_normal));
                    deleteelement(3);
                } else {
                    serve_three.setBackgroundResource(R.drawable.hot2_bigiconorg);
                    tv_hot_water.setTextColor(resources.getColor(R.color.service_text_color));
                    tempList.add(3);
                }
            }
        });

        //食物加热
        serve_four = (ImageView) findViewById(R.id.serve_four);
        serve_four.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                if (tempList.contains(4)) {
                    serve_four.setBackgroundResource(R.drawable.hot_bigicongray);
                    tv_hot_food.setTextColor(resources.getColor(R.color.service_text_color_normal));
                    deleteelement(4);
                } else {
                    serve_four.setBackgroundResource(R.drawable.hot_bigiconorg);
                    tv_hot_food.setTextColor(resources.getColor(R.color.service_text_color));
                    tempList.add(4);
                }
            }
        });

        //打气
        serve_five = (ImageView) findViewById(R.id.serve_five);
        serve_five.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                if (tempList.contains(5)) {
                    serve_five.setBackgroundResource(R.drawable.bigicon_gray);
                    tv_pump.setTextColor(resources.getColor(R.color.service_text_color_normal));
                    deleteelement(5);
                } else {
                    serve_five.setBackgroundResource(R.drawable.bigicon_org);
                    tv_pump.setTextColor(resources.getColor(R.color.service_text_color));
                    tempList.add(5);
                }
            }
        });

        //手机充电
        serve_six = (ImageView) findViewById(R.id.serve_six);
        serve_six.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                if (tempList.contains(6)) {
                    serve_six.setBackgroundResource(R.drawable.dian_bigicongray);
                    tv_battery.setTextColor(resources.getColor(R.color.service_text_color_normal));
                    deleteelement(6);
                } else {
                    serve_six.setBackgroundResource(R.drawable.dian_bigiconorg);
                    tv_battery.setTextColor(resources.getColor(R.color.service_text_color));
                    tempList.add(6);
                }
            }
        });

        //早餐
        serve_seven = (ImageView) findViewById(R.id.serve_seven);
        serve_seven.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                if (tempList.contains(7)) {
                    serve_seven.setBackgroundResource(R.drawable.bre_bigicongray);
                    tv_breaker.setTextColor(resources.getColor(R.color.service_text_color_normal));
                    deleteelement(7);
                } else {
                    serve_seven.setBackgroundResource(R.drawable.bre_bigiconorg);
                    tv_breaker.setTextColor(resources.getColor(R.color.service_text_color));
                    tempList.add(7);
                }
            }
        });

        //快递收发
        serve_eight = (ImageView) findViewById(R.id.serve_eight);
        serve_eight.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                if (tempList.contains(8)) {
                    serve_eight.setBackgroundResource(R.drawable.ex_bigicongray);
                    tv_express.setTextColor(resources.getColor(R.color.service_text_color_normal));
                    deleteelement(8);
                } else {
                    serve_eight.setBackgroundResource(R.drawable.ex_bigiconorg);
                    tv_express.setTextColor(resources.getColor(R.color.service_text_color));
                    tempList.add(8);
                }
            }
        });

        //缴话费
        serve_nine = (ImageView) findViewById(R.id.serve_nine);
        serve_nine.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                if (tempList.contains(9)) {
                    serve_nine.setBackgroundResource(R.drawable.pay_bigicongray);
                    tv_charge.setTextColor(resources.getColor(R.color.service_text_color_normal));
                    deleteelement(9);
                } else {
                    serve_nine.setBackgroundResource(R.drawable.pay_bigiconorg);
                    tv_charge.setTextColor(resources.getColor(R.color.service_text_color));
                    tempList.add(9);
                }
            }
        });

        //鲜奶预定
        serve_ten = (ImageView) findViewById(R.id.serve_ten);
        serve_ten.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                if (tempList.contains(10)) {
                    serve_ten.setBackgroundResource(R.drawable.mill_bigicongray);
                    tv_milk.setTextColor(resources.getColor(R.color.service_text_color_normal));
                    deleteelement(10);
                } else {
                    serve_ten.setBackgroundResource(R.drawable.mill_bigiconorg);
                    tv_milk.setTextColor(resources.getColor(R.color.service_text_color));
                    tempList.add(10);
                }
            }
        });

        //鲜花预定
        serve_eleven = (ImageView) findViewById(R.id.serve_eleven);
        serve_eleven.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                if (tempList.contains(11)) {
                    serve_eleven.setBackgroundResource(R.drawable.fr_bigicongray);
                    tv_flower.setTextColor(resources.getColor(R.color.service_text_color_normal));
                    deleteelement(11);
                } else {
                    serve_eleven.setBackgroundResource(R.drawable.fr_bigiconorg);
                    tv_flower.setTextColor(resources.getColor(R.color.service_text_color));
                    tempList.add(11);
                }
            }
        });

        //蛋糕预定
        serve_twelve = (ImageView) findViewById(R.id.serve_twelve);
        serve_twelve.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                if (tempList.contains(12)) {
                    serve_twelve.setBackgroundResource(R.drawable.ck_bigicongray);
                    tv_cake.setTextColor(resources.getColor(R.color.service_text_color_normal));
                    deleteelement(12);
                } else {
                    serve_twelve.setBackgroundResource(R.drawable.ck_bigiconorg);
                    tv_cake.setTextColor(resources.getColor(R.color.service_text_color));
                    tempList.add(12);
                }
            }
        });

        findViewById(R.id.retreat).setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                finish();
            }
        });


        if (tempList.contains(1)) {
            serve_one.setBackgroundResource(R.drawable.wifi_bigiconorg);
            tv_wifi.setTextColor(resources.getColor(R.color.service_text_color));
        }
        if (tempList.contains(2)) {
            serve_two.setBackgroundResource(R.drawable.wc_bigiconorg);
            tv_wc.setTextColor(resources.getColor(R.color.service_text_color));
        }
        if (tempList.contains(3)) {
            serve_three.setBackgroundResource(R.drawable.hot2_bigiconorg);
            tv_hot_water.setTextColor(resources.getColor(R.color.service_text_color));
        }
        if (tempList.contains(4)) {
            serve_four.setBackgroundResource(R.drawable.hot_bigiconorg);
            tv_hot_food.setTextColor(resources.getColor(R.color.service_text_color));
        }
        if (tempList.contains(5)) {
            serve_five.setBackgroundResource(R.drawable.bigicon_org);
            tv_pump.setTextColor(resources.getColor(R.color.service_text_color));
        }
        if (tempList.contains(6)) {
            serve_six.setBackgroundResource(R.drawable.dian_bigiconorg);
            tv_battery.setTextColor(resources.getColor(R.color.service_text_color));
        }
        if (tempList.contains(7)) {
            serve_seven.setBackgroundResource(R.drawable.bre_bigiconorg);
            tv_breaker.setTextColor(resources.getColor(R.color.service_text_color));
        }
        if (tempList.contains(8)) {
            serve_eight.setBackgroundResource(R.drawable.ex_bigiconorg);
            tv_express.setTextColor(resources.getColor(R.color.service_text_color));
        }
        if (tempList.contains(9)) {
            serve_nine.setBackgroundResource(R.drawable.pay_bigiconorg);
            tv_charge.setTextColor(resources.getColor(R.color.service_text_color));
        }
        if (tempList.contains(10)) {
            serve_ten.setBackgroundResource(R.drawable.mill_bigiconorg);
            tv_milk.setTextColor(resources.getColor(R.color.service_text_color));
        }
        if (tempList.contains(11)) {
            serve_eleven.setBackgroundResource(R.drawable.fr_bigiconorg);
            tv_flower.setTextColor(resources.getColor(R.color.service_text_color));
        }
        if (tempList.contains(12)) {
            serve_twelve.setBackgroundResource(R.drawable.ck_bigiconorg);
            tv_cake.setTextColor(resources.getColor(R.color.service_text_color));
        }
        if (tempList.contains(13)) {
            other_services1.setBackgroundResource(R.drawable.gy_bigiconorg);
            tv_recycle.setTextColor(resources.getColor(R.color.service_text_color));
        }
        if (tempList.contains(14)) {
            other_services2.setBackgroundResource(R.drawable.suo_bigiconorg);
            tv_lock.setTextColor(resources.getColor(R.color.service_text_color));
        }
        if (tempList.contains(15)) {
            other_services3.setBackgroundResource(R.drawable.sh_group);
            tv_move_house.setTextColor(resources.getColor(R.color.service_text_color));
        }
        if (tempList.contains(16)) {
            other_services4.setBackgroundResource(R.drawable.tong_bigiconorg);
            tv_dredge.setTextColor(resources.getColor(R.color.service_text_color));
        }
        if (tempList.contains(17)) {
            other_services5.setBackgroundResource(R.drawable.gx_bigiconorg);
            tv_clothes.setTextColor(resources.getColor(R.color.service_text_color));
        }
        if (tempList.contains(18)) {
            other_services6.setBackgroundResource(R.drawable.group_copyorg);
            tv_serve.setTextColor(resources.getColor(R.color.service_text_color));
        }
        if (tempList.contains(19)) {
            other_services7.setBackgroundResource(R.drawable.pay2_bigiconorg);
            tv_pay.setTextColor(resources.getColor(R.color.service_text_color));
        }
        if (tempList.contains(20)) {
            other_services8.setBackgroundResource(R.drawable.wx_bigiconorg);
            tv_maintain.setTextColor(resources.getColor(R.color.service_text_color));
        }
        if (tempList.contains(21)) {
            other_services9.setBackgroundResource(R.drawable.tool_bigiconorg);
            tv_tools.setTextColor(resources.getColor(R.color.service_text_color));
        }
        if (tempList.contains(22)) {
            other_services10.setBackgroundResource(R.drawable.yyc_bigiconorg);
            tv_toy_car.setTextColor(resources.getColor(R.color.service_text_color));
        }
        if (tempList.contains(23)) {
            other_services11.setBackgroundResource(R.drawable.tx_bigiconorg);
            tv_rent_car.setTextColor(resources.getColor(R.color.service_text_color));
        }
        if (tempList.contains(24)) {
            other_services12.setBackgroundResource(R.drawable.rc_bigiconorg);
            tv_phone_recycle.setTextColor(resources.getColor(R.color.service_text_color));
        }
        if (tempList.contains(25)) {
            other_services13.setBackgroundResource(R.drawable.ly_bigiconorg);
            tv_broadband.setTextColor(resources.getColor(R.color.service_text_color));
        }

        findViewById(R.id.submit).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new Storeinformation(tempList.toString()).start();
            }
        });
        handler = new Handler() {
            @SuppressLint("NewApi")
            @Override
            public void handleMessage(Message msg) {// handler接收到消息后就会执行此方法
                super.handleMessage(msg);
                switch (msg.what) {
                    case 2:
                        Toast.makeText(ServiceActivity.this, "请检查本地网络！",
                                Toast.LENGTH_SHORT).show();
                        break;
                    case 3:
                        Toast.makeText(ServiceActivity.this, error,
                                Toast.LENGTH_SHORT).show();
                        break;
                    case 4:
                        new Stores(MainActivity.app_token, MainActivity.member_id, ServiceActivity.this).start();
                        Toast.makeText(ServiceActivity.this, "上传成功",
                                Toast.LENGTH_SHORT).show();
                        EventBus.getDefault().post(new ServiceUpdateBean(1));
                        finish();


                        break;
                    default:
                        break;
                }
            }
        };
    }

    private void deleteelement(Integer integer) {
        for (int i = tempList.size() - 1; i >= 0; i--) {
            Integer str = tempList.get(i);
            if (str == integer) {
                tempList.remove(str);
            }
        }
    }

    @Override
    public void finish() {
        if (!ifSubmit) {
            tempList.clear();
            tempList.addAll(tempList);
        }
        super.finish();
    }

    private void initView() {
        tv_wifi = (TextView) findViewById(R.id.tv_wifi);
        tv_wc = (TextView) findViewById(R.id.tv_wc);
        tv_hot_water = (TextView) findViewById(R.id.tv_hot_water);
        tv_hot_food = (TextView) findViewById(R.id.tv_hot_food);
        tv_pump = (TextView) findViewById(R.id.tv_pump);
        tv_battery = (TextView) findViewById(R.id.tv_battery);
        tv_breaker = (TextView) findViewById(R.id.tv_breaker);
        tv_express = (TextView) findViewById(R.id.tv_express);
        tv_charge = (TextView) findViewById(R.id.tv_charge);
        tv_pay = (TextView) findViewById(R.id.tv_pay);
        tv_tools = (TextView) findViewById(R.id.tv_tools);
        tv_toy_car = (TextView) findViewById(R.id.tv_toy_car);
        tv_recycle = (TextView) findViewById(R.id.tv_recycle);
        tv_lock = (TextView) findViewById(R.id.tv_lock);
        tv_move_house = (TextView) findViewById(R.id.tv_move_house);
        tv_dredge = (TextView) findViewById(R.id.tv_dredge);
        tv_broadband = (TextView) findViewById(R.id.tv_broadband);
        tv_clothes = (TextView) findViewById(R.id.tv_clothes);
        tv_serve = (TextView) findViewById(R.id.tv_serve);
        tv_cake = (TextView) findViewById(R.id.tv_cake);
        tv_flower = (TextView) findViewById(R.id.tv_flower);
        tv_milk = (TextView) findViewById(R.id.tv_milk);
        tv_rent_car = (TextView) findViewById(R.id.tv_rent_car);
        tv_maintain = (TextView) findViewById(R.id.tv_maintain);
        tv_phone_recycle = (TextView) findViewById(R.id.tv_phone_recycle);
    }


    public class Storeinformation extends Thread {

        private String activity_servcie;

        public Storeinformation(String activity_servcie) {

            this.activity_servcie = activity_servcie;

        }

        public void run() {

            try {
                List<NameValuePair> params = new ArrayList<NameValuePair>();
                params.add(new BasicNameValuePair("app_token", MainActivity.app_token));
                JSONObject paramsone = new JSONObject();

                List<Integer> listTemp = new ArrayList<Integer>();
                Iterator<Integer> it = tempList.iterator();
                while (it.hasNext()) {
                    int a = it.next();
                    if (listTemp.contains(a)) {
                        it.remove();
                    } else {
                        listTemp.add(a);
                    }
                }
                Stores.type_service = listTemp;
                Log.v("zyl", "activity_servcie:" + tempList.toString());
                paramsone.put("activity_servcie", tempList);
                paramsone.put("member_id", MainActivity.member_id);
                params.add(new BasicNameValuePair("params", paramsone.toString()));
                params.add(new BasicNameValuePair("service", "member.storeEdit"));
                String sign = Submit.genPackageSign(params);
                params.add(new BasicNameValuePair("sign", sign));
                JSONObject obj = Submit.submit(params, Stores.http + "/openapi/member");
                String result = obj.getString("rsp_code");
                if (result.equals("succ")) {
                    ifSubmit = true;
                    handler.sendEmptyMessage(4);
                } else {

                    if (goToLogin.setGoToLogin(obj)) {

                    } else {
                        error = (String) obj.get("error");
                        handler.sendEmptyMessage(3);
                    }
                }
            } catch (Exception e) {
                handler.sendEmptyMessage(2);
            }

        }
    }
}
